From: Luiz Angelo Daros de Luca Date: Tue, 23 Nov 2021 02:04:51 +0000 (-0300) Subject: interface-ip: use metric when looking for a route X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=e589c0580dcb9031faec2b8106925874b5d648a1;p=project%2Fnetifd.git interface-ip: use metric when looking for a route When there were multiple routes with the same target but different metrics, __find_ip_route_target was returning the first one, independently of the metric. Signed-off-by: Luiz Angelo Daros de Luca --- diff --git a/interface-ip.c b/interface-ip.c index 648f521..7b63ef9 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -234,7 +234,9 @@ __find_ip_route_target(struct interface_ip_settings *ip, union if_addr *a, if (route->flags & DEVROUTE_TABLE) continue; - if (!*res || route->mask > (*res)->mask) + if (!*res || route->mask > (*res)->mask || + ((route->mask == (*res)->mask) && (route->flags & DEVROUTE_METRIC) + && (route->metric < (*res)->metric))) *res = route; } }